import { createStoreBindings } from 'mobx-miniprogram-bindings'
const store = require('@/store/index')

Page({
  onLoad() {
    this.storeBindings = createStoreBindings(this, {
      store,
      fields: ['counter', 'squareOfCounter'],
      actions: ['increment', 'incrementWithStep']
    })
    wx.nextTick(() => {
      // 在 Page 使用 MobX
      console.log(this.data.counter)
      console.log(this.data.squareOfCounter)
      console.log(this.increment)
      console.log(this.incrementWithStep)
    })
  },

  onUnload() {
    this.storeBindings.destroyStoreBindings()
  },

  onTap() {
    this.incrementWithStep(7)
  }
})